package dongshi.daddy.adapter.objectadpater;

import com.google.common.base.Splitter;
import dongshi.daddy.adapter.Adaptee;
import dongshi.daddy.adapter.Target;

import java.util.List;

// 客户需要的接口实现类，即适配器类
public class TargetObjectAdapter implements Target {
    private Adaptee adaptee;

    public TargetObjectAdapter(Adaptee adaptee) {
        this.adaptee = adaptee;
    }

    public void tellMeYourDream(String content) {
        // 客户给的是逗号分割的字符串，这里适配成现有接口需要的List
        List<String> listResult = Splitter.on(",").splitToList(content);
        // 适配完成，调用现有类的方法
//        super.tellMeYourDream(listResult);
        this.adaptee.tellMeYourDream(listResult);
    }
}